package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.ProductDao;
import com.cn.wanxi.dao.impl.ProductImpl;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.ProductService;

import java.util.List;

public class ProductServiceImpl implements ProductService {
    private ProductDao productDao = new ProductImpl();

    @Override
    public String add(ProductModel productModel) {
        return productDao.add(productModel) > 0 ? "success" : "error";
    }

    @Override
    public String update(ProductModel productModel) {
        return null;
    }

    @Override
    public String delete(ProductModel productModel) {
        return null;
    }

    @Override
    public ResultModel findAll(ProductModel productModel) {
        ProductDao productDao = new ProductImpl();
        return new ResultModel(0, "", productDao.findAll(productModel), productDao.count(productModel));
    }

    @Override
    public ProductModel findById(ProductModel productModel) {
        return null;
    }

    @Override
    public int count(ProductModel productModel) {
        ProductDao productDao = new ProductImpl();
        return productDao.count(productModel);
    }
}
